// stores/departmentStore.js
import { log } from 'console'
import { defineStore } from 'pinia'

export const useDepartmentStore = defineStore('department', {
  state: () => ({
    currentNodeKey: '',
    currentDepartment: '',
    departmentList: []
  }),
  actions: {
    setCurrentNodeKey(key) {
      this.currentNodeKey = key
      // 可选：保存到localStorage
      localStorage.setItem('currentDepartmentNodeKey', key)
    },
    setCurrentDepartment(department) {
      console.log('设置当前部门',department);

      this.currentDepartment = department
    },
    setDepartmentList(list) {
      console.log('设置部门列表',list);

      this.departmentList = list
    }
  },
  persist: true // 如果使用pinia-plugin-persist
})
